package com.zcx.qshop.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.zcx.helper.bound.BoundView;
import com.zcx.qshop.R;
import com.zcx.qshop.adapter.SearchResultAdapter;
import com.zcx.qshop.conn.JsonSerchlistAsyGet;
import com.zcx.qshop.view.TitleView;

/**
 * Created by Administrator on 2015/8/27 0027.
 */
public class SearchResultActivity extends QSActivity {

    @BoundView(R.id.title_view) private TitleView titleView;

    @BoundView(R.id.search_result_list_view) private ListView listView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_search_result);

        final JsonSerchlistAsyGet.Info info = (JsonSerchlistAsyGet.Info) getIntent().getSerializableExtra("Info");

        titleView.showStyle(TitleView.Style.FULL);

        titleView.showType(TitleView.Type.BACK_TWO, TitleView.Type.NAME_ONE);

        titleView.setTitleName("搜索结果");

        titleView.setOnTitleItemClickListener(new TitleView.OnTitleItemClickListener() {

            @Override
            public void onBackClick() {

                finish();

            }

        });

        listView.setAdapter(new SearchResultAdapter(this, info.goods));

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                startVerifyActivity(CommodityDetailActivity.class, new Intent().putExtra("Good", info.goods.get(position)));

            }

        });

    }

}
